﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Stud.DTOs;
using Stud.DataAccess;

namespace Stud.BusinessFacade
{
    public class StudentFacade
    {
        public List<StudentAllInfo> GetAllStudents()
        {
            Queries queries = new Queries();
            return queries.GetStudentInfo();

            //var studs= queries.GetStudentInfo();
            //StudentAllInfo stud = studs.Where(st => st.RollNo == 22).FirstOrDefault();
            //if(stud!=null)
            //{

            //}
        }
        public StudentInfo GetStudentByRollNo(long rollNo)
        {
            return new Queries().GetStudentByRollNo(rollNo);
        }
        //public List<StudentInfo> GetAllStudents()
        //{
        //    Queries queries = new Queries();
        //   return queries.GetStudents();
        //}
        public bool SaveStudent(StudentInfo stud)
        {
            bool success = true;
            try
            {
                Queries queries = new Queries();
                //   queries.AddStudent(stud);
                var studId = queries.AddStudent2(stud);
                queries.UpdateStudent(stud);
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        public void DeleteByRollNo(long rollNo)
        {
            new Queries().DeleteStudentByRollNo(rollNo);
        }
    }
}
